package com.edu.exam.enums;

/**
 * 成绩导出权限级别枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum GradeExportPermissionLevel {
    /** 基础级别 */
    BASIC("BASIC", "基础级别"),
    /** 标准级别 */
    STANDARD("STANDARD", "标准级别"),
    /** 高级级别 */
    ADVANCED("ADVANCED", "高级级别"),
    /** 专家级别 */
    EXPERT("EXPERT", "专家级别"),
    /** 管理员级别 */
    ADMIN("ADMIN", "管理员级别"),
    /** 超级管理员级别 */
    SUPER_ADMIN("SUPER_ADMIN", "超级管理员级别");

    private final String code;
    private final String description;

    GradeExportPermissionLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GradeExportPermissionLevel fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeExportPermissionLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    public static GradeExportPermissionLevel fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeExportPermissionLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}
